<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<!DOCTYPE html>
<html>
<head>
    <title>进口B2C申报服务（保税）--清单异常处理</title>
    <meta content='width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no' name='viewport'/>
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="expires" content="0">
    <%@include file="/WEB-INF/pages/common/taglib.jsp" %>
    <%@include file="/WEB-INF/pages/common/common.jsp" %>
</head>
<body>
<div class="content content_frame">
    <h3 class="mainTitle"><img src="${basePath}/images/icon2.png"/>清单异常处理</h3>
    </br>
    <ul class="contentNav dib-wrap">
        <li class="dib" id="btnSearch" defaultkey='13'>
            <a><i class='fa fa-search'></i>&nbsp;&nbsp;查&nbsp;询 </a>
        </li>
        <li class="dib" id="btnModify" defaultkey='13'>
            <a><i class='fa fa-edit'></i>&nbsp;&nbsp;修&nbsp;改 </a>
        </li>
        <li class="dib" id="btnDeclare" defaultkey='13'>
            <a><i class='fa fa-check'></i>&nbsp;&nbsp;申&nbsp;报 </a>
        </li>
        <li class="dib ">
            <a onclick="ClearAllInput('SearchTable')">
                <i class='fa fa-refresh'></i>&nbsp;&nbsp;重&nbsp;置 </a>
        </li>
    </ul>
    <br/>
    <table id="SearchTable" width="100%" class="table1">
        <tr>
            <td style="width: 25%;">
                <table width="100%" border="0" cellspacing="10" cellpadding="0">
                    <tr>
                        <td class="titleCss">
                            运单号
                        </td>
                        <td class="tdCss">
                            <input type="text" class="input1" datafield="SearchTable.waybillId" placeholder="运单号"/>
                        </td>
                    </tr>
                </table>
            </td>
            <td style="width: 25%;">
                <table width="100%" border="0" cellspacing="10" cellpadding="0">
                    <tr>
                        <td class="titleCss">
                            提运单号
                        </td>
                        <td class="tdCss">
                            <input type="text" class="input1" datafield="SearchTable.billNo" placeholder="提运单号"/>
                        </td>
                    </tr>
                </table>
            </td>
            <td style="width: 25%;">
                <table width="100%" border="0" cellspacing="10" cellpadding="0">
                    <tr>
                        <td class="titleCss">
                            收件人姓名
                        </td>
                        <td class="tdCss">
                            <input type="text" class="input1" datafield="SearchTable.ownerName" placeholder="收件人姓名"/>
                        </td>
                    </tr>
                </table>
            </td>
            <td style="width: 25%;">
                <table width="100%" border="0" cellspacing="10" cellpadding="0">
                    <tr>
                        <td class="titleCss">
                            申报单位名称
                        </td>
                        <td class="tdCss">
                            <input type="text" class="input1" datafield="SearchTable.agentName" placeholder="申报单位名称"/>
                        </td>
                    </tr>
                </table>
            </td>
        </tr>
        <tr>
            <td style="width: 25%;">
                <table width="100%" border="0" cellspacing="10" cellpadding="0">
                    <tr>
                        <td class="titleCss">
                            商户名称
                        </td>
                        <td class="tdCss">
                            <input type="text" class="input1" datafield="SearchTable.ebName" placeholder="商户名称"/>
                        </td>
                    </tr>
                </table>
            </td>
            <td style="width: 25%;">
                <table width="100%" border="0" cellspacing="10" cellpadding="0">
                    <tr>
                        <td class="titleCss">
                            平台名称
                        </td>
                        <td class="tdCss">
                            <input type="text" class="input1" datafield="SearchTable.ebPlatName" placeholder="平台名称"/>
                        </td>
                    </tr>
                </table>
            </td>
            <td style="width: 25%;">
                <table width="100%" border="0" cellspacing="10" cellpadding="0">
                    <tr>
                        <td class="titleCss">
                            物流企业名称
                        </td>
                        <td class="tdCss">
                            <input type="text" class="input1" datafield="SearchTable.logiEnteName"
                                   placeholder="物流企业名称"/>
                        </td>
                    </tr>
                </table>
            </td>
            <td style="width: 25%;">
                <table width="100%" border="0" cellspacing="10" cellpadding="0">
                    <tr>
                        <td class="titleCss">
                            状态
                        </td>
                        <td class="tdCss">
                            <ui:tsingletableautocomplete
                                    key="ITEM_KEY"
                                    value="ITEM_VALUE"
                                    tableName="DICT_ITEM"
                                    groupId="ORDER_STATUS_QDC"
                                    keyFieldName="status"
                                    valueFieldName="statusXXX"/>
                        </td>
                    </tr>
                </table>
            </td>
        </tr>
    </table>
    <div class="cl"></div>
    <br/>
    <table id="corptable">
    </table>
    <div id="corptablePage">
    </div>
</div>
<script type="text/javascript">
    function urlCode(cellvalue, options, rowObject) {
        var url = '${basePath}/declareDetailQdc/declareDetail/' + rowObject.id;
        return "<a class='btn-link' href=\"" + url + "\">" + "<span style='color:#00acec'>" + cellvalue + "</span></a>";
    }

    $(function () {
        $("#corptable").jqGrid({
            datatype: "json",
            url: $basePath + "/importB2CTax/exception/queryDeclareList",
            colNames: [
                'id', '', '状态',
                '运单号',
                '提运单号',
                '申报口岸',
                '出入境时间',
                '收件人姓名',
                '收件人证件号',
                '申报单位名称',
                '商户名称',
                '平台名称',
                '物流企业名称',
                '监管场所名称',
                '启运国',
                '运输方式',
                '运输工具',
                '航次',
                '成交总价',
                '币制',
                '重量',
                '总件数'
            ],
            colModel: [
                {name: 'id', index: 'id', hidden: true},
                {name: 'status', index: 'status', hidden: true},
                {name: 'statusDisplay', index: 'statusDisplay', formatter: status},
                {name: 'waybillId', index: 'waybillId'},
                {name: 'billNo', index: 'billNo', formatter: urlCode},
                {name: 'declPortDisplay', index: 'declPort'},
                {name: 'ieDate', index: 'ieDate', width: 300},
                {name: 'ownerName', index: 'ownerName'},
                {name: 'ownerCertId', index: 'ownerCertId', width: 300},
                {name: 'agentName', index: 'agentName'},
                {name: 'ebName', index: 'ebName'},
                {name: 'ebPlatName', index: 'ebPlatName'},
                {name: 'logiEnteName', index: 'logiEnteName'},
                {name: 'superPlaceName', index: 'superPlaceName'},
                {name: 'tradeCountDisplay', index: 'tradeCount'},
                {name: 'trafModeDisplay', index: 'trafMode'},
                {name: 'trafName', index: 'trafName'},
                {name: 'voyageNo', index: 'voyageNo'},
                {name: 'transTotalPrice', index: 'transTotalPrice'},
                {name: 'currCodeDisplay', index: 'currCodeDisplay'},
                {name: 'grossWeight', index: 'grossWeight'},
                {name: 'packNum', index: 'packNum'}
            ],
            viewrecords: true,
            autowidth: true,
            height: 'auto',
            shrinkToFit: false,
            autoScroll: true,
            rowNum: 10, //每页显示记录数
            rowList: [10, 20, 100], //可调整每页显示的记录数
            rownumbers: true,
            rownumWidth: 15,
            multiselect: true,
            pager: "#corptablePage", //分页工具栏
            sortname: "ieDate",
            sortorder: "desc",
            loadComplete: function () {
                var rowNum = $(this).jqGrid('getGridParam', 'records');
                if (rowNum <= 0) {
                    if ($(this).parent().children('.norecords').length == 0)
                        $(this).parent().append("<div class=\"norecords\">暂无数据！</div>");
                    $(this).parent().children('.norecords').show();
                }
                else {
                    $(this).parent().children('.norecords').hide();
                }

                $(".ui-jqgrid tr.ui-row-ltr td").css('text-align', 'center');
            }
        });

        $("#btnSearch").bind("click", function () {
            reloadGrid();
        });
    });

    function reloadGrid() {
        var jsonStr = customFormToData("SearchTable");
        $("#corptable").jqGrid('setGridParam', {
            url: $basePath + "/importB2CTax/exception/queryDeclareList",
            postData: JSON.parse(jsonStr), //发送数据
            page: 1
        }).trigger("reloadGrid"); //重新载入
    }

    $(function () {
        $("#btnModify").bind("click", function () {
            var jsonArr = getId("corptable");
            if (1 != jsonArr.length) {
                ShowMessages("请选择一条记录进行修改", "系统提示", "msgwaring", null, 0);
            } else {
                location.href = '${basePath}/declareDetailQdc/declareDetail/' + jsonArr[0].id + "?flag=1";
            }
        });

        $("#btnDeclare").bind("click", function () {
            var jsonArr = getId("corptable");
            if (0 == jsonArr.length) {
                ShowMessages("请选择需要申报的记录", "系统提示", "msgwaring", null, 0);
                return;
            }
            var str = "";
            for (var i in jsonArr) {
                str += jsonArr[i].id + ",";
            }
            $.post("${basePath}/importB2CTax/exception/declare", {id: str.substring(0, str.length - 1)}, function (data) {
                if (data) {
                    ShowMessages("已上报，请等待回执", "系统提示", "msgok", function () {
                        window.location.reload();
                    }, 0);
                } else {
                    ShowMessages(data, "系统提示", "msgwaring", function () {
                        window.location.reload();
                    }, 0);
                }
            });
        });
    });
</script>
</body>
</html>
